<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>editerTab</title>
    <script>
        YMWL_ROOT_URL = '{:request()->root()}';
    </script>
    <script type="text/javascript" src="__libs__/jquery/jquery.min.js?v=__lkversion__"></script>
    <link href="__libs__/amaze/css/amazeui.min.css?v=__lkversion__" type="text/css" rel="stylesheet"/>
    <script src="__libs__/amaze/js/amazeui.min.js?v=__lkversion__" type="text/javascript"></script>
    <script src="__libs__/layer/layer.js?v=__lkversion__" type="text/javascript"></script>
    <script src="__libs__/layui/layui.js?v=__lkversion__" type="text/javascript"></script>
    <link href="__libs__/layui/css/layui.css?v=__lkversion__" rel="stylesheet">

</head>

<style type="text/css">
    * {
        margin: 0;
        padding: 0;
    }

    #tab_title {
        font-size: 13px;
        color: #555555;
        border: 1px solid #e5e3e9;
        border-radius: 8px;
    }

    button.keep {
        width: 66px;
        height: 36px;
        color: #ffffff;
        font-size: 13px;
        background-color: #7571f9;
        border-radius: 16px;
    }

    button.reset {
        width: 66px;
        height: 36px;
        color: #555555;
        font-size: 13px;
        background-color: #f7f7f7;
        border-radius: 16px;
        border: 0;
    }
</style>
<body>

<div style="width: 100%;margin: 10px auto;">
    <div class="layui-form-item layui-form-text">
        <textarea id="custom" placeholder="请输入内容" class="layui-textarea" style="width:100%;height: 300px;border: 1px solid #e5e3e9;border-radius:
8px;resize:none;">{$content}</textarea>
    </div>

    <div class="layui-form-item" style="margin-top: 24px;text-align: center">
        <button class="layui-btn keep" onclick="setcustom()" lay-submit lay-filter=" template">保存</button>
        <button type="reset" onclick="reset()" class="layui-btn layui-btn-primary reset">取消</button>
    </div>
</div>
<script type="text/javascript" src="__assets__/ueditor/ueditor.config.js"></script>
<script type="text/javascript" src="__assets__/ueditor/ueditor.all.js"></script>
<script type="text/javascript">
    var editorOption = {
        UEDITOR_HOME_URL: "__assets__/ueditor/",
        UEDITOR_ROOT_URL: "__assets__/ueditor/",
        serverUrl: "{:url('upload/ueditor',['action'=>'config','service_id'=>$_SESSION['Msg']['service_id'],'admin_id'=>0])}",
        lang: "zh-cn",
        toolbars: [["undo", "redo", "|", "bold", "italic", "underline", "fontborder", "strikethrough", "superscript", "subscript", "removeformat", "formatmatch", "autotypeset", "blockquote", "pasteplain", "|", "forecolor", "backcolor",  "selectall", "cleardoc", "|","lineheight", "|", "customstyle", "paragraph", "fontfamily", "fontsize", "|",  "link", "unlink","|", "simpleupload", "insertimage", "emotion"]],
        initialContent: "",
        pageBreakTag: "_ueditor_page_break_tag_",
        initialFrameWidth: "100%",
        initialFrameHeight: "300",
        initialStyle: "body{font-size:14px}",
        autoFloatEnabled: false,
        allowDivTransToP: true,
        autoHeightEnabled: false,
        charset: "utf-8",
    };
    var DomUe=UE.getEditor("custom",editorOption)
</script>
</body>

<script>
    var lock = false;

    function setcustom() {
        var content = DomUe.getContent();
        var id = {$sid};
        if (content) {
            if (!lock) {
                lock = true;
                $.ajax({
                    url: YMWL_ROOT_URL + '/admin/set/setcustom',
                    type: 'post',
                    data: {content: content, sid: id},
                    success: function (res) {

                        if (res.code == 0) {
                            layer.msg(res.msg, {
                                icon: 1, end: function () {
                                    parent.location.reload();
                                }
                            })
                        } else {
                            layer.msg(res.msg, {iocn: 2});
                        }
                    }
                });
            }
        } else {
            layer.msg('数据不完整', {iocn: 2});
        }
    }
    function reset() {
        parent.layer.closeAll();
    }
</script>
</html>